package com.example.video.adapter

import android.widget.CheckBox
import android.widget.TextView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.Car
import com.example.video.R

class CarAdapter:BaseQuickAdapter<Car,BaseViewHolder>(R.layout.item_car) {
    override fun convert(holder: BaseViewHolder, item: Car) {
        holder.getView<CheckBox>(R.id.car_cb).isChecked = item.isCheck
        Glide.with(context).load(item.image).into(holder.getView(R.id.car_image))
        holder.setText(R.id.car_name,item.storeName)
        holder.setText(R.id.car_attr,"属性：${item.suk}")
        holder.setText(R.id.car_price,"￥${item.price}")
        holder.setText(R.id.car_num,"${item.cartNum}")//数字一定要注意转成 字符串
        //当数量为1时 减不能点击了
        if(item.cartNum==1){
            holder.getView<TextView>(R.id.car_sub).isEnabled = false
        }else{
            holder.getView<TextView>(R.id.car_sub).isEnabled = true
        }
    }
}